package com.tanhua.api.mongo;

import com.tanhua.mongo.Visitors;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@Service
public class MovementsApiImpl implements MovementsApi {

    @Autowired
    private MongoTemplate mongoTemplate;


    @Override
    public List<Visitors> findVisitors(Long id, Long time) {

        Query query = new Query(Criteria.where("userId").is(id).and("date").gt(time));
        List<Visitors> list = mongoTemplate.find(query, Visitors.class);
        return list;
    }
}
